package com.pachong.frameworkdemo.app;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RadioButton;

import com.pachong.android.framework.commonui.RadioButtonBottomTabFragment;
import com.pachong.android.frameworkbase.customviews.BadgeRadioButton;
import com.pachong.frameworkdemo.R;
import com.pachong.frameworkdemo.module1.Main1Fragment;
import com.pachong.frameworkdemo.module2.Main2Fragment;
import com.pachong.frameworkdemo.module3.Main3Fragment;
import com.pachong.frameworkdemo.module4.TemplateImageVPFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 主界面的fragment
 *
 * @Author: PV
 * @E-mail: pengveivei@sina.cn
 * @CreateDate: 2016/6/24 15:47
 * @Version: 1.0.0
 */
public class MainBottomFragment extends RadioButtonBottomTabFragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);

        Button btn = (Button) inflater.inflate(R.layout.main_bottom_button, container, false);
        addButton(btn, 2);

        setRadioButtonInterruptCheckedListener(3, new BadgeRadioButton.OnInterruptCheckedListener() {
            @Override
            public boolean onInterruptChecked(View view, boolean checked) {
                return false; // interrupt checked event
            }
        });

        RadioButton rbtn1 = (RadioButton) inflater.inflate(R.layout.main_bottom_radio_button, container, false);
        addButton(rbtn1, 1);

        return view;
    }

    @Override
    public List<PageInfo> createPages() {

        Fragment main1Frag = new Main1Fragment();
        Fragment main2Frag = new Main2Fragment();
        Fragment main3Frag = new Main3Fragment();
        Fragment main4Frag = new TemplateImageVPFragment();
        Fragment[] fragments = new Fragment[]{main1Frag, main2Frag, main3Frag, main4Frag};
        String[] TITLES = new String[]{"page1", "自定UI", "page3", "page4"};
        final int[] ICONS = new int[]{R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher};

        List<PageInfo> pageList = new ArrayList<>();
        for (int i = 0; i < TITLES.length; i++) {
            pageList.add(new PageInfo(fragments[i], TITLES[i], ICONS[i]));
        }

        return pageList;
    }
}
